//
// Created by nicemoe on 2021/8/30.
//

#include  <iostream>
#include <cstdlib>
#include <ctime>
#include "stacktp1.h"
using namespace std;
const int Num = 10;
int main()
{

    srand(time(0));
    cout <<"Please enter stack size: ";
    int stacksize;
    cin >> stacksize;
    Stack<const char *> st(stacksize);
    const char * in[Num] = {
        "1: Hank Gilgamesh",
        "2 :Kiki Ishtar",
        "3 :Betty Rocker",
        "4 :Ian Flagranti",
        "5 :Wolfgang Kibble",
        "6 :Portia Koop",
        "7 :Joy Almondo",
        "8 :Xaverie Paprika",
        "9 :Juan Moore",
        "10 :Misha Mache",
    };
    const char * out[Num] = {nullptr};

    int processed = 0;
    int nextin = 0;
    while (processed < Num){
        if (st.isEmpty())
            st.push(in[nextin++]);
        else if (st.isFull())
            st.pop(out[processed++]);
        else if (rand() % 2 && nextin < Num)
            st.push(in[nextin++]);
        else
            st.pop(out[processed++]);
    }
    for (int i = 0; i < Num; i++) {
        if (out[i] == nullptr){
            continue;
        }
        cout << out[i] <<endl;
    }
    cout <<"Bye \n";
    return 0;
}
